{{template "layout" .}}
{{define "content"}}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
  <!-- Content Header (Page header) -->
  <section class="content-header">
    <h1>
      租户列表
      <small>app list</small>
    </h1>
    <ol class="breadcrumb">
      <li><a href="/admin/app_list"><i class="fa fa-dashboard"></i> Home</a></li>
      <li class="active">租户列表</li>
    </ol>
  </section>

  <!-- Main content -->
  <section class="content">
    <div class="row">
      <div class="col-xs-12">
        <div class="box">
          <div class="box-header">
            <h3 class="box-title">服务管理</h3>
            <div class="btn-group pull-right" style="margin-right: 10px">
              <a href="/admin/add_app/" class="btn btn-sm btn-success"><i class="fa fa-save"></i>&nbsp;&nbsp;新增租户</a>
            </div>
          </div>
          <!-- /.box-header -->
          <div class="box-body">
            <table id="example2" class="table table-bordered table-hover">
              <thead>
              <tr>
                <th>ID</th>
                <th>app_id</th>
                <th>租户名称</th>
                <th>secret</th>
                <th>QPS</th>
                <th>QPD</th>
                <th>操作</th>
              </tr>
              </thead>
              <tbody>
              {{range .List}}
                <tr>
                  <td>{{.GatewayAPP.ID}}</td>
                  <td>{{.GatewayAPP.AppID}}</td>
                  <td>{{.GatewayAPP.Name}}</td>
                  <td>{{.GatewayAPP.Secret}}</td>
                  <td>{{.QPS}}/{{.GatewayAPP.QPS}}</td>
                  <td>{{.QPD}}/{{.GatewayAPP.TotalQueryDaily}}</td>
                  <td>
                    <button type="button" class="btn btn-xs btn-danger waves-effect m-b-5" onclick='location.href="/admin/app_detail?app_id={{.AppID}}";' value="流量统计">流量统计</button>
                    <button type="button" class="btn btn-xs btn-danger waves-effect m-b-5" onclick='location.href="/admin/edit_app?app_id={{.AppID}}";' value="修改">修改</button>
                    <button type="button" class="btn btn-xs btn-danger waves-effect m-b-5" onclick='if (confirm("确认要删除吗？")){location.href="/admin/del_app?app_id={{.AppID}}"};' value="删除">删除</button>
                  </td>
                </tr>
              {{ end }}
              </tbody>
            </table>
          </div>
          <!-- /.box-body -->
        </div>
        <!-- /.box -->
      </div>
      <!-- /.col -->
    </div>
    <!-- /.row -->
  </section>
  <!-- /.content -->
</div>
<!-- /.content-wrapper -->
{{end}}
{{define "script"}}
<!-- page script -->
<script>
  $(function () {
    $('#example2').DataTable({
      'paging'      : true,
      'lengthChange': false,
      'searching'   : false,
      'ordering'    : false,
      'info'        : false,
      'autoWidth'   : false
    })
  })
</script>
{{end}}